
local Config = require("Config")
local lua_mongo = _G.lua_mongo

-- 加db第一步 请先确认是否要建对应字段的索引 第二步请确认合服逻辑是否要修改 如果不确认
db_char                     =	    Config.DB_NAME .. ".char"	            -- 角色表
db_mail                     =       Config.DB_NAME .. ".mail"               -- 邮件数据库表
db_friend                   =       Config.DB_NAME .. ".friend"             -- 好友数据库表
db_family                   =       Config.DB_NAME .. ".family"    	        -- 军团数据库表
db_server                   =       Config.DB_NAME .. ".server"             -- 服务器全局相关
db_rank                     =       Config.DB_NAME .. ".rank"               -- 排行榜相关
db_pay                      =       Config.DB_NAME .. ".pay"                -- 充值记录表
db_market                   =       Config.DB_NAME .. ".market"             -- 市场记录表
db_worldboss                =       Config.DB_NAME .. ".worldboss"          -- 世界BOSS
db_wildboss                 =       Config.DB_NAME .. ".wildboss"           -- 野外BOSS
db_adminBroadcast           =       Config.DB_NAME .. ".adminBroadcast"     -- 广播
db_taskPool                 =       Config.DB_NAME .. ".taskPool"           -- 日常任务池
db_dyMonster                =       Config.DB_NAME .. ".dyMonster"          -- 动态属性怪物
db_open_middle			    =		Config.DB_NAME .. ".open_middle"		    -- 跨服是否开启 
db_operateact               =       Config.DB_NAME .. ".operateact"         -- 运营活动
db_complexact               =       Config.DB_NAME .. ".complexact"         -- 合服活动
db_dateact                  =       Config.DB_NAME .. ".dateact"            -- 定时活动
db_middleFamilyWar          =       Config.DB_NAME .. ".middleFamilyWar"    -- 跨服军团战
db_middleFamilyWarStatus    =       Config.DB_NAME .. ".middleFamilyWarStatus"    -- 跨服军团战状态

-- 加db第一步 请先确认是否要建对应字段的索引 第二步请确认合服逻辑是否要修改 如果不确认

local function init()
    if has_init then
        return
    end
    has_init = true
    lua_mongo.client(Config.DB_IP)
    lua_mongo.auth(Config.DB_NAME, Config.DB_USER, Config.DB_PASS)
    lua_mongo.index(db_char, "name")
    lua_mongo.index(db_char, "account")
    lua_mongo.index(db_char, "zhandouli")
    lua_mongo.index(db_char, "lv")
    lua_mongo.index(db_char, "yinliang")
    lua_mongo.index(db_char, "offlinePkRank")
    lua_mongo.index(db_mail, "receiverUuid")
    lua_mongo.index(db_pay,  "account")
    lua_mongo.index(db_market, "_id")
    lua_mongo.index(db_worldboss, "actNum")
    lua_mongo.index(db_wildboss, "actNum")
    lua_mongo.index(db_taskPool, "groupID")
    lua_mongo.index(db_dyMonster, "monsterID")
    lua_mongo.index(db_operateact, "actConfig")
    lua_mongo.index(db_complexact, "actConfig")
    lua_mongo.index(db_dateact, "actConfig")
    lua_mongo.index(db_middleFamilyWar, "rank")
end

init()
